/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: syyyy
 * Date: 2025-10-22
 * Time: 22:02
 */
public class Test {
    public static String longestCommonPrefix(String[] strs){
        if(strs.length == 0){
            return null;
        }
        String ans=strs[0];
        for (int i = 1; i < strs.length; i++) {
            int j=0;
            for (; j < ans.length() && j < strs[i].length(); j++) {
                if(ans.charAt(j) != strs[i].charAt(j)){
                    break;
                }
            }
            ans=ans.substring(0,j);
            if(ans.equals("")){
                return ans;
            }
        }
        return ans;
    }
    public static void main(String[] args) {

    }
}
